#include "assert.h"
#include "queue.h"

void QueueIni(Queue* cola){
        cola->ini &= 0;
        cola->fin &= 0;
}

char QueueIsEmpty(Queue* cola){
  if (cola->ini==cola->fin){
    return 1;
  }
  else {
    return 0;
  }
}

char QueueIsFull(Queue* cola){
  if (cola->ini==(cola->fin+1)){
    return 1;
  }
  else {
    return 0;
  }
}

void QueueAdd(Queue* cola, char i){
  assert(QueueIsFull(cola)==0);
  cola->q[cola->fin] = i;
  cola->fin++;
  if (cola->fin==QUEUE_SIZE){
    cola->fin = 0;
  }      
}

char QueueGet(Queue* cola){
  char aux;
  assert(QueueIsEmpty(cola)==0);
  aux = (cola->q[cola->ini++]);
  if (cola->ini==QUEUE_SIZE){
    cola->ini = 0;
  }
  return aux;
}
